
let deliveryData={
  "searchCount": true,
  "current": 1,
  "pages": 1,
  "size": 20,
  "total": 3,
   "records": [
     {
       "dataId":133,
       "deptId": 3,
       "deptName": " 业务中心/交付部",
       "staffId": 674,
       "staffJob": 74,
       "staffJobName": "交付专员",
       "staffName": "测AADIC",
       "targetUpdateDate": "2024-08-15",
       "sysUserHead": 'http://test291.ims.in/files/excel/11/2024/9/1840204368046350338.png',
       "target":8,
       "complete":7,
       "remark":"大江东去，浪淘尽、千古风流人物。故垒西边，人道是、三国周郎赤壁。乱石穿空，惊涛拍岸，卷起千堆雪。江山如画，一时多少豪杰。遥想公瑾当年，小乔初嫁了，雄姿英发。羽扇纶巾，谈笑间、樯橹灰飞烟灭。故国神游，多情应笑我，早生华发。人生如梦，一樽还酹江月。"
       },{
        "dataId":12,
        "deptId": 3,
        "deptName": " 业务中心/交付部",
        "staffId": 673,
        "staffJob": 73,
        "staffJobName": "交付专员",
        "staffName": "测AADIB",
        "sysUserHead": 'http://test291.ims.in/files/excel/11/2024/9/1840204368046350338.png',
        "targetUpdateDate": "2024-08-16 11:59:36",
        "target":12,
        "complete":8,
        "remark":"大江东去，浪淘尽、千古风流人物。故垒西边，人道是、三国周郎赤壁。乱石穿空，惊涛拍岸，卷起千堆雪。江山如画，一时多少豪杰。遥想公瑾当年，小乔初嫁了，雄姿英发。羽扇纶巾，谈笑间、樯橹灰飞烟灭。故国神游，多情应笑我，早生华发。人生如梦，一樽还酹江月。"
       },{
        "dataId":133,
        "deptId": 3,
        "deptName": " 业务中心/交付部",
        "staffId": 674,
        "staffJob": 74,
        "staffJobName": "交付专员",
        "staffName": "测AADIC",
        "targetUpdateDate": "2024-08-15",
        "sysUserHead": 'http://test291.ims.in/files/excel/11/2024/9/1840204368046350338.png',
        "target":8,
        "complete":7,
        "remark":"大江东去，浪淘尽、千古风流人物。故垒西边，人道是、三国周郎赤壁。乱石穿空，惊涛拍岸，卷起千堆雪。江山如画，一时多少豪杰。遥想公瑾当年，小乔初嫁了，雄姿英发。羽扇纶巾，谈笑间、樯橹灰飞烟灭。故国神游，多情应笑我，早生华发。人生如梦，一樽还酹江月。"
        },{
         "dataId":12,
         "deptId": 3,
         "deptName": " 业务中心/交付部",
         "staffId": 673,
         "staffJob": 73,
         "staffJobName": "交付专员",
         "staffName": "测AADIB",
         "sysUserHead": 'http://test291.ims.in/files/excel/11/2024/9/1840204368046350338.png',
         "targetUpdateDate": "2024-08-16 11:59:36",
         "target":12,
         "complete":8,
         "remark":"大江东去，浪淘尽、千古风流人物。故垒西边，人道是、三国周郎赤壁。乱石穿空，惊涛拍岸，卷起千堆雪。江山如画，一时多少豪杰。遥想公瑾当年，小乔初嫁了，雄姿英发。羽扇纶巾，谈笑间、樯橹灰飞烟灭。故国神游，多情应笑我，早生华发。人生如梦，一樽还酹江月。"
        },{
          "dataId":133,
          "deptId": 3,
          "deptName": " 业务中心/交付部",
          "staffId": 674,
          "staffJob": 74,
          "staffJobName": "交付专员",
          "staffName": "测AADIC",
          "targetUpdateDate": "2024-08-15",
          "sysUserHead": 'http://test291.ims.in/files/excel/11/2024/9/1840204368046350338.png',
          "target":8,
          "complete":7,
          "remark":"大江东去，浪淘尽、千古风流人物。故垒西边，人道是、三国周郎赤壁。乱石穿空，惊涛拍岸，卷起千堆雪。江山如画，一时多少豪杰。遥想公瑾当年，小乔初嫁了，雄姿英发。羽扇纶巾，谈笑间、樯橹灰飞烟灭。故国神游，多情应笑我，早生华发。人生如梦，一樽还酹江月。"
          },{
           "dataId":12,
           "deptId": 3,
           "deptName": " 业务中心/交付部",
           "staffId": 673,
           "staffJob": 73,
           "staffJobName": "交付专员",
           "staffName": "测AADIB",
           "sysUserHead": 'http://test291.ims.in/files/excel/11/2024/9/1840204368046350338.png',
           "targetUpdateDate": "2024-08-16 11:59:36",
           "target":12,
           "complete":8,
           "remark":"大江东去，浪淘尽、千古风流人物。故垒西边，人道是、三国周郎赤壁。乱石穿空，惊涛拍岸，卷起千堆雪。江山如画，一时多少豪杰。遥想公瑾当年，小乔初嫁了，雄姿英发。羽扇纶巾，谈笑间、樯橹灰飞烟灭。故国神游，多情应笑我，早生华发。人生如梦，一樽还酹江月。"
          },{
            "dataId":133,
            "deptId": 3,
            "deptName": " 业务中心/交付部",
            "staffId": 674,
            "staffJob": 74,
            "staffJobName": "交付专员",
            "staffName": "测AADIC",
            "targetUpdateDate": "2024-08-15",
            "sysUserHead": 'http://test291.ims.in/files/excel/11/2024/9/1840204368046350338.png',
            "target":8,
            "complete":7,
            "remark":"大江东去，浪淘尽、千古风流人物。故垒西边，人道是、三国周郎赤壁。乱石穿空，惊涛拍岸，卷起千堆雪。江山如画，一时多少豪杰。遥想公瑾当年，小乔初嫁了，雄姿英发。羽扇纶巾，谈笑间、樯橹灰飞烟灭。故国神游，多情应笑我，早生华发。人生如梦，一樽还酹江月。"
            },{
             "dataId":12,
             "deptId": 3,
             "deptName": " 业务中心/交付部",
             "staffId": 673,
             "staffJob": 73,
             "staffJobName": "交付专员",
             "staffName": "测AADIB",
             "sysUserHead": 'http://test291.ims.in/files/excel/11/2024/9/1840204368046350338.png',
             "targetUpdateDate": "2024-08-16 11:59:36",
             "target":12,
             "complete":8,
             "remark":"大江东去，浪淘尽、千古风流人物。故垒西边，人道是、三国周郎赤壁。乱石穿空，惊涛拍岸，卷起千堆雪。江山如画，一时多少豪杰。遥想公瑾当年，小乔初嫁了，雄姿英发。羽扇纶巾，谈笑间、樯橹灰飞烟灭。故国神游，多情应笑我，早生华发。人生如梦，一樽还酹江月。"
            },{
       "dataId":133,
       "deptId": 3,
       "deptName": " 业务中心/交付部",
       "staffId": 674,
       "staffJob": 74,
       "staffJobName": "交付专员",
       "staffName": "测AADIC",
       "targetUpdateDate": "2024-08-15",
       "sysUserHead": 'http://test291.ims.in/files/excel/11/2024/9/1840204368046350338.png',
       "target":8,
       "complete":7,
       "remark":"大江东去，浪淘尽、千古风流人物。故垒西边，人道是、三国周郎赤壁。乱石穿空，惊涛拍岸，卷起千堆雪。江山如画，一时多少豪杰。遥想公瑾当年，小乔初嫁了，雄姿英发。羽扇纶巾，谈笑间、樯橹灰飞烟灭。故国神游，多情应笑我，早生华发。人生如梦，一樽还酹江月。"
       },{
        "dataId":12,
        "deptId": 3,
        "deptName": " 业务中心/交付部",
        "staffId": 673,
        "staffJob": 73,
        "staffJobName": "交付专员",
        "staffName": "测AADIB",
        "sysUserHead": 'http://test291.ims.in/files/excel/11/2024/9/1840204368046350338.png',
        "targetUpdateDate": "2024-08-16 11:59:36",
        "target":12,
        "complete":8,
        "remark":"大江东去，浪淘尽、千古风流人物。故垒西边，人道是、三国周郎赤壁。乱石穿空，惊涛拍岸，卷起千堆雪。江山如画，一时多少豪杰。遥想公瑾当年，小乔初嫁了，雄姿英发。羽扇纶巾，谈笑间、樯橹灰飞烟灭。故国神游，多情应笑我，早生华发。人生如梦，一樽还酹江月。"
       },{
        "dataId":133,
        "deptId": 3,
        "deptName": " 业务中心/交付部",
        "staffId": 674,
        "staffJob": 74,
        "staffJobName": "交付专员",
        "staffName": "测AADIC",
        "targetUpdateDate": "2024-08-15",
        "sysUserHead": 'http://test291.ims.in/files/excel/11/2024/9/1840204368046350338.png',
        "target":8,
        "complete":7,
        "remark":"大江东去，浪淘尽、千古风流人物。故垒西边，人道是、三国周郎赤壁。乱石穿空，惊涛拍岸，卷起千堆雪。江山如画，一时多少豪杰。遥想公瑾当年，小乔初嫁了，雄姿英发。羽扇纶巾，谈笑间、樯橹灰飞烟灭。故国神游，多情应笑我，早生华发。人生如梦，一樽还酹江月。"
        },{
         "dataId":12,
         "deptId": 3,
         "deptName": " 业务中心/交付部",
         "staffId": 673,
         "staffJob": 73,
         "staffJobName": "交付专员",
         "staffName": "测AADIB",
         "sysUserHead": 'http://test291.ims.in/files/excel/11/2024/9/1840204368046350338.png',
         "targetUpdateDate": "2024-08-16 11:59:36",
         "target":12,
         "complete":8,
         "remark":"大江东去，浪淘尽、千古风流人物。故垒西边，人道是、三国周郎赤壁。乱石穿空，惊涛拍岸，卷起千堆雪。江山如画，一时多少豪杰。遥想公瑾当年，小乔初嫁了，雄姿英发。羽扇纶巾，谈笑间、樯橹灰飞烟灭。故国神游，多情应笑我，早生华发。人生如梦，一樽还酹江月。"
        },{
          "dataId":133,
          "deptId": 3,
          "deptName": " 业务中心/交付部",
          "staffId": 674,
          "staffJob": 74,
          "staffJobName": "交付专员",
          "staffName": "测AADIC",
          "targetUpdateDate": "2024-08-15",
          "sysUserHead": 'http://test291.ims.in/files/excel/11/2024/9/1840204368046350338.png',
          "target":8,
          "complete":7,
          "remark":"大江东去，浪淘尽、千古风流人物。故垒西边，人道是、三国周郎赤壁。乱石穿空，惊涛拍岸，卷起千堆雪。江山如画，一时多少豪杰。遥想公瑾当年，小乔初嫁了，雄姿英发。羽扇纶巾，谈笑间、樯橹灰飞烟灭。故国神游，多情应笑我，早生华发。人生如梦，一樽还酹江月。"
          },{
           "dataId":12,
           "deptId": 3,
           "deptName": " 业务中心/交付部",
           "staffId": 673,
           "staffJob": 73,
           "staffJobName": "交付专员",
           "staffName": "测AADIB",
           "sysUserHead": 'http://test291.ims.in/files/excel/11/2024/9/1840204368046350338.png',
           "targetUpdateDate": "2024-08-16 11:59:36",
           "target":12,
           "complete":8,
           "remark":"大江东去，浪淘尽、千古风流人物。故垒西边，人道是、三国周郎赤壁。乱石穿空，惊涛拍岸，卷起千堆雪。江山如画，一时多少豪杰。遥想公瑾当年，小乔初嫁了，雄姿英发。羽扇纶巾，谈笑间、樯橹灰飞烟灭。故国神游，多情应笑我，早生华发。人生如梦，一樽还酹江月。"
          },{
            "dataId":133,
            "deptId": 3,
            "deptName": " 业务中心/交付部",
            "staffId": 674,
            "staffJob": 74,
            "staffJobName": "交付专员",
            "staffName": "测AADIC",
            "targetUpdateDate": "2024-08-15",
            "sysUserHead": 'http://test291.ims.in/files/excel/11/2024/9/1840204368046350338.png',
            "target":8,
            "complete":7,
            "remark":"大江东去，浪淘尽、千古风流人物。故垒西边，人道是、三国周郎赤壁。乱石穿空，惊涛拍岸，卷起千堆雪。江山如画，一时多少豪杰。遥想公瑾当年，小乔初嫁了，雄姿英发。羽扇纶巾，谈笑间、樯橹灰飞烟灭。故国神游，多情应笑我，早生华发。人生如梦，一樽还酹江月。"
            },{
             "dataId":12,
             "deptId": 3,
             "deptName": " 业务中心/交付部",
             "staffId": 673,
             "staffJob": 73,
             "staffJobName": "交付专员",
             "staffName": "测AADIB",
             "sysUserHead": 'http://test291.ims.in/files/excel/11/2024/9/1840204368046350338.png',
             "targetUpdateDate": "2024-08-16 11:59:36",
             "target":12,
             "complete":8,
             "remark":"大江东去，浪淘尽、千古风流人物。故垒西边，人道是、三国周郎赤壁。乱石穿空，惊涛拍岸，卷起千堆雪。江山如画，一时多少豪杰。遥想公瑾当年，小乔初嫁了，雄姿英发。羽扇纶巾，谈笑间、樯橹灰飞烟灭。故国神游，多情应笑我，早生华发。人生如梦，一樽还酹江月。"
            }
   ]
 }
const getDataList =(req, res)=> {
  const { pageNum, pageSize, sort, sortType, staffName, year, month } = req.body;
  const data = [...deliveryData.records]
  let filteredData = [...data];
  let result = {}
  if (staffName) {
    filteredData = filteredData.filter(item => item.staffName.includes(staffName));
  }
  if (sort && sortType) {
    filteredData.sort((a, b) => {
      if (sort === 'asc') {
        return new Date(a[sortType]) - new Date(b[sortType]);
      } else {
        return new Date(b[sortType]) - new Date(a[sortType]);
      }
    });
  }

  // 计算分页的起始索引和结束索引
  const startIndex = (pageNum - 1) * pageSize;
  const endIndex = pageNum * pageSize;

  // 根据索引切片获取当前页的数据
  const paginatedData = filteredData.slice(startIndex, endIndex);

  // 设置返回结果中的数据部分
  // result.data = paginatedData;

  // 设置返回结果中的总记录数
  // result.total = filteredData.length;

  result = {
    records: paginatedData,
    current: pageNum,
    pages: 4,
    total: filteredData.total,
    size: pageSize,
  }
  res.send({ error_code: 200, error_msg: 'OK', data: result });
}

const getDtailById = (req, res) => {
  const {dataId}= req.query
  const data = deliveryData.records.find(item => item.dataId == dataId);
  res.send({ error_code: 200, error_msg: 'OK', data: data})
  
}

export default {
  'POST /api/deliveryPlan/getDataList':getDataList,  //获取交付计划列表
  'GET /api/deliveryPlan/getDetailById':getDtailById, //根据id获取交付计划详情
}